dojo.declare("MShopCartPg", wm.Page, {
start: function() {
},
"preferredDevice": "phone",
button1Click: function(inSender) {
//method for new check out
//wm.Page.getPage("MCustomerHomePg").vPageBack = "CHECK_OUT";
var accountId = app.vAccount.data.accountId;
if (accountId) {
this.largeTextArea1.clear();
//hide the search
var totalPrice = 0;
this.totalOrderAmount = 0;
for (var count = 0; count < app.vCartItems.getCount(); count++) {
var vItem = app.vCartItems.getItem(count);
// alert(vItem.data.tax);
if (vItem.data.quantity > 0) {
var qty = vItem.data.quantity;
// alert('price' + vItem.data.itemPrice);
var price = (qty * vItem.data.itemPrice);
price = Math.round(price * 100) / 100;
totalPrice = totalPrice + price;
totalPrice = Math.round(totalPrice * 100) / 100;
//alert('totalPrice' + totalPrice);
}
}
if (app.vCartItems.getCount() > 0) {
this.totalOrderAmount = totalPrice;
this.layerPlaceOrder.activate();
this.panel2.setShowing(true);
this.labelTotalOrderPrice.setShowing(true);
// this.labelSelectItem.setShowing(false);
this.labelTotalOrderPrice.setCaption("Total:" + totalPrice + " Rs");
this.buttonConfirmOrder.setShowing(true);
// this.labelReviewOrder.setShowing(true);
// this.panel9.setShowing(false);
} else {
app.toastWarning("Please Select atleast one Item", 2000);
// this.labelReviewOrder.setShowing(false);
// this.labelSelectItem.setShowing(true);
this.labelTotalOrderPrice.setShowing(false);
this.buttonConfirmOrder.setShowing(false);
}
} else {
app.toastWarning("Please login to checkout", 2000);
wm.getPage("MHomePg").navButton2.click();
}
},
buttonConfirmOrderClick: function(inSender) {
if (this.totalOrderAmount > 0) {
// this.svCompleteOrder.input.setValue("order.customerId", mainPage.vUserId);
// this.svCompleteOrder.update();
this.layerOrderResult.activate();
} else {
app.toastWarning("Please select atleast one item", 2000);
}
},
svPlaceOrderSuccess1: function(inSender, inDeprecated) {
app.vCartItems.clearData();
},
buttonBackClick: function(inSender) {
if (wm.Page.getPage("MHomePg")) {
wm.Page.getPage("MHomePg").navButton1.click();
}
},
listShoppingCartItemNameFormat: function(inValue, rowId, cellId, cellField, cellObj, rowObj) {
var itemsFormat = "<div class='MobileRow'>" + " " + rowObj.itemName + "</div>" + "<div class='MobileRow'>" + " " + rowObj.unit + "</div>" + "<div class='MobileRow'>" + "Selected Quantity: " + rowObj.quantity + "</div>" + "<div class='MobileRow'>" + "Item Price: " + rowObj.itemPrice + " " + rowObj.currency + "</div>";
return itemsFormat;
},
listShoppingCartSelect: function(inSender, inItem) {
var quantity = this.listShoppingCart.selectedItem.getData().quantity;
if (quantity) {
this.txtQuantity.setDisplayValue(quantity);
}
this.designableDialog1.show();
},
bAddQtyClick: function(inSender) {
if (this.txtQuantity) {
// alert(isNaN(this.txtQuantity.getDataValue()));
if (this.txtQuantity.getDisplayValue()) {
this.txtQuantity.setDisplayValue(+this.txtQuantity.getDataValue() + 1);
} else {
this.txtQuantity.setDisplayValue(1);
}
}
},
bRemoveQtyClick: function(inSender) {
if (this.txtQuantity) {
if (this.txtQuantity.getDisplayValue() > 0) {
this.txtQuantity.setDisplayValue(+this.txtQuantity.getDisplayValue() - 1);
} else {
this.txtQuantity.setDisplayValue(0);
}
}
},
bAddToCartClick: function(inSender) {
if (+this.txtQuantity.getDataValue() > 0) {
var selItemId = this.listShoppingCart.selectedItem.getData().itemId;
var homeMenu = wm.Page.getPage("MHomeMenuPg");
for (var count = 0; count < homeMenu.lvItems.getCount(); count++) {
var vItem = homeMenu.lvItems.getItem(count);
if (vItem.data.itemId === selItemId) {
if (app.vCartItems.getCount() > 0) {
var isMatchFound = false;
var cartCount = app.vCartItems.getCount();
for (var count1 = 0; count1 < cartCount; count1++) {
var vcartItem = app.vCartItems.getItem(count1);
if (vcartItem.data.itemId === selItemId) {
vcartItem.data.quantity = +this.txtQuantity.getDataValue();
vItem.data.quantity = this.txtQuantity.getDataValue();
app.vCartItems.setItem(count1, vcartItem);
homeMenu.lvItems.setItem(count, vItem);
isMatchFound = true;
}
}
if (!isMatchFound) {
vItem.data.quantity = +this.txtQuantity.getDataValue();
homeMenu.lvItems.setItem(count, vItem);
app.vCartItems.addItem(vItem);
}
} else {
vItem.data.quantity = +this.txtQuantity.getDataValue();
homeMenu.lvItems.setItem(count, vItem);
app.vCartItems.addItem(vItem, count);
// var vItem1 = this.lvItems.getItem(count);
// alert(vItem1.data.quantity);
}
}
}
}
this.designableDialog1.hide();
},
_end: 0
});

MShopCartPg.widgets = {
svPlaceOrder: ["wm.ServiceVariable", {"inFlightBehavior":"executeLast","operation":"placeOrder","service":"OrderService"}, {"onSuccess":"ncOrderSuccess","onSuccess1":"svPlaceOrderSuccess1"}, {
input: ["wm.ServiceInput", {"type":"placeOrderInputs"}, {}, {
binding: ["wm.Binding", {}, {}, {
wire: ["wm.Wire", {"expression":undefined,"source":"largeTextArea1.dataValue","targetProperty":"order.comment"}, {}],
wire1: ["wm.Wire", {"expression":undefined,"source":"app.vCartItems","targetProperty":"order.items"}, {}],
wire2: ["wm.Wire", {"expression":undefined,"source":"app.vAccount.accountId","targetProperty":"order.customerId"}, {}]
}]
}]
}],
ncOrderSuccess: ["wm.NotificationCall", {"operation":"toast"}, {}, {
input: ["wm.ServiceInput", {"type":"toastInputs"}, {}, {
binding: ["wm.Binding", {}, {}, {
wire: ["wm.Wire", {"expression":"\"Order Placed Sucessfully\"","targetProperty":"text"}, {}],
wire1: ["wm.Wire", {"expression":"3000","targetProperty":"duration"}, {}],
wire2: ["wm.Wire", {"expression":"\"Success\"","targetProperty":"cssClasses"}, {}],
wire3: ["wm.Wire", {"expression":"\"center center\"","targetProperty":"dialogPosition"}, {}]
}]
}]
}],
designableDialog1: ["wm.DesignableDialog", {"buttonBarId":"buttonBar","containerWidgetId":"containerWidget","height":"100%","title":"Add To cart","width":"100%"}, {}, {
containerWidget: ["wm.Container", {"_classes":{"domNode":["wmdialogcontainer","MainContent"]},"autoScroll":true,"height":"100%","horizontalAlign":"left","padding":"5","verticalAlign":"top","width":"100%"}, {}, {
panel16: ["wm.Panel", {"height":"307px","horizontalAlign":"left","verticalAlign":"top","width":"100%"}, {}, {
label8: ["wm.Label", {"height":"30px","padding":"4","width":"100%"}, {}, {
binding: ["wm.Binding", {}, {}, {
wire: ["wm.Wire", {"expression":undefined,"source":"listShoppingCart.selectedItem.itemName","targetProperty":"caption"}, {}]
}]
}],
panel17: ["wm.Panel", {"height":"108px","horizontalAlign":"left","layoutKind":"left-to-right","verticalAlign":"top","width":"100%"}, {}, {
picture7: ["wm.Picture", {"aspect":"h"}, {}, {
binding: ["wm.Binding", {}, {}, {
wire: ["wm.Wire", {"expression":undefined,"source":"listShoppingCart.selectedItem.imageUr","targetProperty":"source"}, {}]
}]
}],
panel18: ["wm.Panel", {"height":"100%","horizontalAlign":"left","verticalAlign":"middle","width":"100%"}, {}, {
label10: ["wm.Label", {"align":"left","height":"30px","padding":"4","width":"100%"}, {}, {
binding: ["wm.Binding", {}, {}, {
wire: ["wm.Wire", {"expression":undefined,"source":"listShoppingCart.selectedItem.unit","targetProperty":"caption"}, {}]
}]
}],
label11: ["wm.Label", {"height":"30px","padding":"4","width":"100%"}, {}, {
binding: ["wm.Binding", {}, {}, {
wire: ["wm.Wire", {"expression":"${listShoppingCart.selectedItem.itemPrice} + ' ' +${listShoppingCart.selectedItem.currency}","targetProperty":"caption"}, {}]
}]
}]
}]
}],
label9: ["wm.Label", {"height":"100%","padding":"4","singleLine":false,"width":"100%"}, {}, {
binding: ["wm.Binding", {}, {}, {
wire: ["wm.Wire", {"expression":undefined,"source":"listShoppingCart.selectedItem.itemDesc","targetProperty":"caption"}, {}]
}]
}]
}],
panel14: ["wm.Panel", {"height":"60px","horizontalAlign":"left","layoutKind":"left-to-right","verticalAlign":"middle","width":"100%"}, {}, {
bRemoveQty: ["wm.Button", {"border":"1","caption":undefined,"height":"50px","iconHeight":"20px","iconWidth":"20px","imageIndex":14,"imageList":"app.silkIconList","margin":"4","mobileHeight":"50px","width":"69px"}, {"onclick":"bRemoveQtyClick"}],
txtQuantity: ["wm.Number", {"border":"0","caption":"Quantity","captionAlign":"center","captionSize":"75px","dataValue":undefined,"desktopHeight":"35px","displayValue":"","height":"40px","mobileHeight":"40px","singleLine":false,"width":"130px"}, {}],
bAddQty: ["wm.Button", {"border":"1","caption":undefined,"height":"50px","imageIndex":1,"imageList":"app.silkIconList","margin":"4","mobileHeight":"50px","width":"70px"}, {"onclick":"bAddQtyClick"}]
}]
}],
buttonBar: ["wm.ButtonBarPanel", {"border":"1,0,0,0","borderColor":"black","height":"43px","mobileHeight":"43px"}, {}, {
panel15: ["wm.Panel", {"height":"100%","horizontalAlign":"left","verticalAlign":"top","width":"100%"}, {}, {
button4: ["wm.Button", {"border":"1","caption":"Cancel","height":"40px"}, {"onclick":"designableDialog1.hide","onclick1":"button4Click1"}]
}],
bAddToCart: ["wm.Button", {"border":"1","caption":"Add to cart","height":"40px","imageIndex":22,"imageList":"app.silkIconList","margin":"4","width":"100px"}, {"onclick":"bAddToCartClick"}]
}]
}],
layoutBox1: ["wm.Layout", {"horizontalAlign":"left","verticalAlign":"top"}, {}, {
layers1: ["wm.Layers", {}, {}, {
layer1: ["wm.Layer", {"borderColor":"","caption":"layer1","horizontalAlign":"left","themeStyleType":"","verticalAlign":"top"}, {}, {
panel1: ["wm.Panel", {"height":"100%","horizontalAlign":"center","verticalAlign":"middle","width":"100%"}, {}, {
listShoppingCart: ["wm.List", {"_classes":{"domNode":["MobileListStyle"]},"columns":[
{"show":true,"field":"itemId","title":"ItemId","width":"80px","align":"left","formatFunc":"","mobileColumn":false},
{"show":true,"field":"itemName","title":"ItemName","width":"100%","align":"left","formatFunc":"listShoppingCartItemNameFormat","mobileColumn":true},
{"show":true,"field":"itemDesc","title":"ItemDesc","width":"100%","align":"left","formatFunc":"","mobileColumn":false},
{"show":true,"field":"outOfStock","title":"OutOfStock","width":"100%","align":"left","formatFunc":"","mobileColumn":false},
{"show":true,"field":"unit","title":"Unit","width":"100%","align":"left","formatFunc":"","mobileColumn":false},
{"show":true,"field":"discount","title":"Discount","width":"80px","align":"left","formatFunc":"","mobileColumn":false},
{"show":true,"field":"vendorPrice","title":"VendorPrice","width":"80px","align":"left","formatFunc":"","mobileColumn":false},
{"show":true,"field":"availibilityStartDt","title":"AvailibilityStartDt","width":"80px","align":"left","formatFunc":"wm_date_formatter","mobileColumn":false},
{"show":true,"field":"availibilityEndDt","title":"AvailibilityEndDt","width":"80px","align":"left","formatFunc":"wm_date_formatter","mobileColumn":false},
{"show":true,"field":"tax","title":"Tax","width":"80px","align":"left","formatFunc":"","mobileColumn":false},
{"show":true,"field":"active","title":"Active","width":"100%","align":"left","formatFunc":"","mobileColumn":false},
{"show":true,"field":"imageUr","title":"ImageUr","width":"100%","align":"left","formatFunc":"","mobileColumn":false},
{"show":true,"field":"currency","title":"Currency","width":"100%","align":"left","formatFunc":"","mobileColumn":false},
{"show":true,"field":"otherCharges","title":"OtherCharges","width":"80px","align":"left","formatFunc":"","mobileColumn":false},
{"show":true,"field":"deliveryCharges","title":"DeliveryCharges","width":"80px","align":"left","formatFunc":"","mobileColumn":false},
{"show":false,"field":"serviceTax","title":"ServiceTax","width":"80px","align":"left","formatFunc":"","mobileColumn":false},
{"show":false,"field":"vat","title":"Vat","width":"80px","align":"left","formatFunc":"","mobileColumn":false},
{"show":false,"field":"baseValue","title":"BaseValue","width":"80px","align":"left","formatFunc":"","mobileColumn":false},
{"show":false,"field":"updatedBy","title":"UpdatedBy","width":"100%","align":"left","formatFunc":"","mobileColumn":false},
{"show":false,"field":"updatedTs","title":"UpdatedTs","width":"80px","align":"left","formatFunc":"wm_date_formatter","mobileColumn":false},
{"show":false,"field":"itemPrice","title":"ItemPrice","width":"80px","align":"left","formatFunc":"","mobileColumn":false},
{"show":false,"field":"quantity","title":"Quantity","width":"80px","align":"left","formatFunc":"","mobileColumn":false},
{"show":false,"field":"PHONE COLUMN","title":"-","width":"100%","align":"left","expression":"\"<div class='MobileRowTitle'>\" +\n\"ItemId: \" + ${itemId} +\n\"</div>\"\n\n+ \"<div class='MobileRow'>\" +\n\"ItemDesc: \" + ${itemDesc}\n + \"</div>\"\n\n+ \"<div class='MobileRow'>\" +\n\"OutOfStock: \" + ${outOfStock}\n + \"</div>\"\n\n+ \"<div class='MobileRow'>\" +\n\"Unit: \" + ${unit}\n + \"</div>\"\n\n+ \"<div class='MobileRow'>\" +\n\"Discount: \" + ${discount}\n + \"</div>\"\n\n+ \"<div class='MobileRow'>\" +\n\"VendorPrice: \" + ${vendorPrice}\n + \"</div>\"\n\n+ \"<div class='MobileRow'>\" +\n\"AvailibilityStartDt: \" + ${wm.runtimeId}.formatCell(\"availibilityStartDt\", ${availibilityStartDt}, ${this}, ${wm.rowId})\n + \"</div>\"\n\n+ \"<div class='MobileRow'>\" +\n\"AvailibilityEndDt: \" + ${wm.runtimeId}.formatCell(\"availibilityEndDt\", ${availibilityEndDt}, ${this}, ${wm.rowId})\n + \"</div>\"\n\n+ \"<div class='MobileRow'>\" +\n\"Tax: \" + ${tax}\n + \"</div>\"\n\n+ \"<div class='MobileRow'>\" +\n\"Active: \" + ${active}\n + \"</div>\"\n\n+ \"<div class='MobileRow'>\" +\n\"ImageUr: \" + ${imageUr}\n + \"</div>\"\n\n+ \"<div class='MobileRow'>\" +\n\"Currency: \" + ${currency}\n + \"</div>\"\n\n+ \"<div class='MobileRow'>\" +\n\"OtherCharges: \" + ${otherCharges}\n + \"</div>\"\n\n+ \"<div class='MobileRow'>\" +\n\"DeliveryCharges: \" + ${deliveryCharges}\n + \"</div>\"\n\n","mobileColumn":false},
{"show":true,"controller":"rightarrow","width":"20px","title":"-","field":"_rightArrow","mobileColumn":true}
],"headerVisible":false,"height":"100%","margin":"0","minDesktopHeight":60,"rightNavArrow":true,"styleAsGrid":false}, {"onSelect":"listShoppingCartSelect"}, {
binding: ["wm.Binding", {}, {}, {
wire: ["wm.Wire", {"expression":undefined,"source":"app.vCartItems","targetProperty":"dataSet"}, {}],
wire1: ["wm.Wire", {"expression":"!${app.vCartItems.isEmpty}","targetProperty":"showing"}, {}]
}]
}],
label12: ["wm.Label", {"align":"center","caption":"Shopping Cart is Empty,Please shop!!","height":"100px","padding":"4","singleLine":false,"styles":{"backgroundColor":"#5fb7f2"},"width":"95%"}, {}, {
binding: ["wm.Binding", {}, {}, {
wire: ["wm.Wire", {"expression":"${app.vCartItems.isEmpty}","targetProperty":"showing"}, {}]
}]
}]
}],
panel4: ["wm.Panel", {"height":"41px","horizontalAlign":"left","layoutKind":"left-to-right","verticalAlign":"top","width":"100%"}, {}, {
button1: ["wm.Button", {"border":"1","caption":"Checkout","height":"40px","margin":"4","styles":{}}, {"onclick":"button1Click"}, {
binding: ["wm.Binding", {}, {}, {
wire: ["wm.Wire", {"expression":"!${app.vCartItems.isEmpty}","targetProperty":"showing"}, {}]
}]
}]
}]
}],
layerPlaceOrder: ["wm.Layer", {"autoScroll":true,"borderColor":"","caption":"layer1","horizontalAlign":"center","styles":{},"themeStyleType":"","verticalAlign":"top"}, {"onShow":"layerPlaceOrderShow"}, {
containerWidget1: ["wm.Container", {"_classes":{"domNode":["wmdialogcontainer","MainContent"]},"autoScroll":true,"height":"100%","horizontalAlign":"center","padding":"1","styles":{},"verticalAlign":"top","width":"100%"}, {}, {
panel3: ["wm.Panel", {"autoScroll":true,"height":"100%","horizontalAlign":"center","styles":{},"verticalAlign":"top","width":"100%"}, {}, {
panel6: ["wm.Panel", {"height":"177px","horizontalAlign":"left","verticalAlign":"top","width":"100%"}, {}, {
label2: ["wm.Label", {"caption":"Delivery Address","padding":"4"}, {}],
label1: ["wm.Label", {"height":"110px","padding":"4","width":"100%"}, {}, {
binding: ["wm.Binding", {}, {}, {
wire: ["wm.Wire", {"expression":undefined,"source":"app.vAccount.address","targetProperty":"caption"}, {}]
}]
}],
panel7: ["wm.Panel", {"height":"35px","horizontalAlign":"left","layoutKind":"left-to-right","verticalAlign":"top","width":"100%"}, {}, {
label3: ["wm.Label", {"caption":"Contact #","height":"35px","padding":"4","singleLine":false,"width":"89px"}, {}],
label4: ["wm.Label", {"align":"left","height":"35px","padding":"4","width":"100%"}, {}, {
binding: ["wm.Binding", {}, {}, {
wire: ["wm.Wire", {"expression":undefined,"source":"app.vAccount.cellPhone","targetProperty":"caption"}, {}]
}]
}]
}]
}],
largeTextArea1: ["wm.LargeTextArea", {"border":"0","caption":"Add Order Comments","captionAlign":"center","captionSize":"20px","dataValue":undefined,"desktopHeight":"81px","displayValue":"","height":"105px","mobileHeight":"105px","padding":"0","styles":{"fontSize":"12px"},"width":"90%"}, {}]
}],
buttonBar2: ["wm.Panel", {"_classes":{"domNode":["dialogfooter"]},"border":"1,0,0,0","desktopHeight":"32px","enableTouchHeight":true,"height":"41px","horizontalAlign":"right","layoutKind":"left-to-right","mobileHeight":"41px","styles":{},"verticalAlign":"top","width":"100%"}, {}, {
bCancelOrder: ["wm.Button", {"border":"1","caption":"Cancel","height":"40px","imageIndex":6,"imageList":"app.silkIconList","margin":"4","styles":{},"width":"75undefined"}, {"onclick":"layer1"}],
panel2: ["wm.Panel", {"border":"1","borderColor":"#121010","height":"100%","horizontalAlign":"left","styles":{"backgroundColor":"#ffffff"},"verticalAlign":"middle","width":"100%"}, {}, {
labelTotalOrderPrice: ["wm.Label", {"align":"left","caption":"Total:","height":"100%","margin":"2","padding":"2","singleLine":false,"styles":{"fontWeight":"bolder","fontSize":"14px","backgroundColor":"#f0dddd"},"width":"100%"}, {}]
}],
buttonConfirmOrder: ["wm.Button", {"border":"1","caption":"Confirm Order","height":"40px","imageIndex":88,"imageList":"app.silkIconList","margin":"4","styles":{},"width":"108.5px"}, {"onclick":"svPlaceOrder","onclick1":"buttonConfirmOrderClick"}]
}]
}]
}],
layerOrderResult: ["wm.Layer", {"borderColor":"","caption":"layer1","horizontalAlign":"left","themeStyleType":"","verticalAlign":"middle"}, {}, {
panel5: ["wm.Panel", {"height":"100%","horizontalAlign":"center","verticalAlign":"middle","width":"100%"}, {}, {
labelOrderResults: ["wm.Label", {"align":"center","height":"150px","padding":"4","singleLine":false,"styles":{"color":"#e61d34","fontWeight":"bold","fontSize":"14px"},"width":"80%"}, {}, {
binding: ["wm.Binding", {}, {}, {
wire: ["wm.Wire", {"expression":undefined,"source":"svPlaceOrder.dataValue","targetProperty":"caption"}, {}]
}]
}],
buttonBack: ["wm.Button", {"border":"1","caption":"< Back","height":"40px","imageIndex":3,"imageList":undefined,"styles":{},"width":"250.80000019073486px"}, {"onclick":"buttonBackClick"}]
}]
}]
}]
}]
};

MShopCartPg.prototype._cssText = '';
MShopCartPg.prototype._htmlText = '';